import util.BackUp
import model.DateSearchCondition
import java.text.SimpleDateFormat

class SystemController {

    def systemLogService
    
    def static String backDBStr = "备份数据库"
    
    def info = {
        def rootRealPath = servletContext.getRealPath("/")
        def classesRealPath = servletContext.getRealPath("/WEB-INF/classes")
        def servletContextName = servletContext.getServletContextName()
        [rootRealPath:rootRealPath , classesRealPath:classesRealPath , servletContextName:servletContextName]
    }

    def backDB = {
    }

    def backUp = {
        def userName = session.user.getUserName()
        systemLogService.writeLog(backDBStr,userName)
        BackUp.backup()
        render (view:"backDBSuccess")
    }

    def backUpTime = { DateSearchCondition searchCondition ->
        def backTime = searchCondition.backTime
        def userName = session.user.getUserName()
        systemLogService.writeLogBackUpTime(backTime,userName)
        BackUp.backUpOnTime(backTime)
        render (view:"backDBOnTimeSuccess",model:[backTime:backTime])
    }

}
